<?php

/**
 * @filename udp.php 
 * @encoding UTF-8 
 * @author  fwz 
 * @datetime 2018-6-7  17:38:56
  */

$serv = new swoole_server('0,0,0,0',9502,SWOOLE_PROCESS,SWOOLE_SOCK_UDP);

//接收到UDP数据包时回调此函数

$serv->on("packet",function($serv,$data,$fd){
    //发送数据到客户端，反馈数据
    $serv->sendto($fd['address'],$fd['port'],"server:$data");
    var_dump($fd);
    
});

$serv->start();

